package com.ala4.oxcafe.repository.mapper;

import com.ala4.oxcafe.entity.RoleInfo;
import com.ala4.oxcafe.entity.UserRoleRel;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Set;

/**
 * 用户角色关联表
 *
 * @author PING
 * @version 1.0.0
 * @date 2025/8/12 12:44
 */
public interface UserRoleRelMapper extends BaseMapper<UserRoleRel> {

    @Select("<script>" +
            "select t.id,t.role_code,t.role_name,r.user_id from role_info t " +
            "right join user_role_rel r on t.id = r.role_id and r.del_flag = 0 " +
            "where t.del_flag = 0 and r.user_id in " +
            "<foreach collection='userIds' item='item' open='(' separator=',' close=')'>#{item}</foreach>" +
            "</script>")
    List<RoleInfo> selectUserRole(@Param("userIds") Set<Long> userIds);
}
